package org.qqcui.designpattern.patterns.interpreter;

import java.util.Map;

/**
 * 变量表达式，根据key获取变量的值
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/7 11:01
 **/
public class VarExpression extends Expression {

    private String key;

    public VarExpression(String key) {
        this.key = key;
    }


    @Override
    public int interpreter(Map<String, Integer> var) {
        return var.get(key);
    }
}
